package com.yangxinxin.lesson.controller;

import com.yangxinxin.lesson.entity.SysUser;
import com.yangxinxin.lesson.service.UserService;
import com.yangxinxin.lesson.vo.RequestVo.LoginReqVo;
import com.yangxinxin.lesson.vo.RequestVo.RegistReqVo;
import com.yangxinxin.lesson.vo.RespondVo.LoginRespVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/** @Author yangxinxin
 * @Description //TODO
 * @Date 17:09 2020/2/21
 * @Param 
 * @return 
 **/
/**前后端分离的模式 数据交互json格式*/
@RestController
@RequestMapping("/api")
@Api(tags = "用户模块",description = "用户登陆相关接口")
public class UserController {
    //2拿到服务层实例
    @Autowired
    private UserService userService;
    @PostMapping("/user/login")
    @ApiOperation(value = "用户登陆接口")
    //1
    public LoginRespVo login(@RequestBody LoginReqVo vo){
        return  userService.login(vo);
    }
    //获取用户详情
    @GetMapping("/user/{id}")
    @ApiOperation(value = "获取用户详细信息接口")
    public SysUser getUserInfo(@PathVariable("id")  String id){
        return userService.getUserInfo(id);
    }
    //用户注册接口
    @PostMapping("/user/register")
    @ApiOperation(value = "用户注册接口")
    //1
    public String register(@RequestBody RegistReqVo vo){
        return  userService.register(vo);
    }

    @GetMapping("/user/code/{phone}")
    public  String getCode(@PathVariable("phone") String phone){
        return  userService.getCode(phone);
    }
}
